<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title>收入记录</title>
		<script src="js/mui.min.js"></script>
		<link href="css/mui.min.css" rel="stylesheet" />
		<link rel="stylesheet" href="css/base.css" />
		<script src="js/flexible.js"></script>
		<link rel="stylesheet" href="css/shourujilu.css" />
		<script src="js/jquery-3.1.1.js"></script>
		<script type="text/javascript" src="js/confi.js"></script>
		<script type="text/javascript" src="js/template.js"></script>

	</head>

	<body>
		<header class="mui-bar mui-bar-nav">
			<a  class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
			<h1 class="mui-title">收入记录</h1>
		</header>
		<table border="" cellspacing="" cellpadding="" style="width: 100%;margin-top: 44px;margin-bottom: 70.5px;">
			<thead>
				<tr>
					<th>类型</th>
					<th>金额</th>
					<th>时间</th>
				</tr>
			</thead>
			<tbody id="shouruCon">
				<!--<tr>
					<td>合并提现</td>
					<td><span>￥</span><span>10.00</span></td>
					<td><span>10-00</span> <span>10:00</span></td>
				</tr>
				<tr>
					<td>合并提现</td>
					<td><span>￥</span><span>10.00</span></td>
					<td><span>10-00</span> <span>10:00</span></td>
				</tr>
				<tr>
					<td>免3分润</td>
					<td><span>￥</span><span>10.00</span></td>
					<td><span>10-00</span> <span>10:00</span></td>
				</tr>
				<tr>
					<td>合并提现</td>
					<td><span>￥</span><span>10.00</span></td>
					<td><span>10-00</span> <span>10:00</span></td>
				</tr>
				<tr>
					<td>合并提现</td>
					<td><span>￥</span><span>10.00</span></td>
					<td><span>10-00</span> <span>10:00</span></td>
				</tr>
				<tr>
					<td>发3分润</td>
					<td><span>￥</span><span>10.00</span></td>
					<td><span>10-00</span> <span>10:00</span></td>
				</tr>
				<tr>
					<td>合并提现</td>
					<td><span>￥</span><span>10.00</span></td>
					<td><span>10-00</span> <span>10:00</span></td>
				</tr>
				<tr>
					<td>合并提现</td>
					<td><span>￥</span><span>10.00</span></td>
					<td><span>10-00</span> <span>10:00</span></td>
				</tr>
				<tr>
					<td>合并提现</td>
					<td><span>￥</span><span>10.00</span></td>
					<td><span>10-00</span> <span>10:00</span></td>
				</tr>
				<tr>
					<td>合并提现</td>
					<td><span>￥</span><span>10.00</span></td>
					<td><span>10-00</span> <span>10:00</span></td>
				</tr>
				<tr>
					<td>合并提现</td>
					<td><span>￥</span><span>10.00</span></td>
					<td><span>10-00</span> <span>10:56</span></td>
				</tr>-->

			</tbody>
		</table>
		<div class="mui-content-padded">
			<ul class="mui-pager">
				<li class="mui-previous">
					<a id="previousPage" href="#" style="background-color: #999999;color: #fff;">
						上一页
					</a>
				</li>
				<li class="mui-previous">
					<a href="#" id="yema">
						<span id="current">1</span>/<span id="sum"></span>
					</a>
				</li>
				<li class="mui-next">
					<a id="nextPage" href="#" style="background-color:#FF3333;color: #fff;">
						下一页
					</a>
				</li>
			</ul>
		</div>
		<script type="text/template" id="shouru">
			{{each items as value index}}
			<tr>
				<td>{{value.note}}</td>
				<td><span>￥</span><span>{{value.money}}</span></td>
				<td><span>{{value.create_time}}</span></td>
			</tr>
			{{/each}}
		</script>
		<script type="text/javascript" charset="utf-8">
			mui.init();
			var token = localStorage.getItem('token');
			var pageN=5;//每页显示的条数
			income(1, pageN);
			//获取收入记录
			function income(page, pageN) {
				mui.ajax(config.host + "/home/User/revenueRecord", {
					headers: {
						'token': token
					},
					dataType: 'json', //服务器返回json格式数据
					type: 'post', //HTTP请求类型	
					data: {
						page: page,
						pageN: pageN
					},
					success: function(data) {
						if(data.code == 200) {
							if(data.data.length != 0) {
								var sum=Math.ceil(data.data.total/pageN);
								$('#sum').text(sum);
								var shouruHtml = template('shouru', {
									"items": data.data.data
								});
								$('#shouruCon').html(shouruHtml);
							} else {
								$('#shouruCon').html('暂无数据');
								$('#shouruCon').css({
									'height': '50px',
									'line-height': '50px',
									"text-align": 'center'
								});
							}
						} else {
							mui.toast("数据获取失败");
						}
					}
				})
			}
			//点击上一页
			$('#previousPage').on('tap',function(){
				var page=Number($("#current").text())-1;
				if(page>=1){
					income(page,pageN);
					$("#current").text(page);
				}else{
					mui.toast('当前是首页');
				}
			})
			//点击下一页
			$('#nextPage').on('tap',function(){
				var page=Number($("#current").text())+1;
				if(page<=$('#sum').text()){
					income(page,pageN);
					$("#current").text(page);
				}else{
					mui.toast('当前是末页');
				}
			})
			
		</script>
	</body>

</html>